package com.example.makerspace.service.impl;

import com.example.makerspace.dto.ContactInfoDTO;
import com.example.makerspace.dto.PageRequest;
import com.example.makerspace.dto.PageResult;
import com.example.makerspace.dto.Result;
import com.example.makerspace.manager.*;
import com.example.makerspace.service.CoalitionService;
import com.example.makerspace.utils.JwtUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Service
public class CoalitionServiceImpl implements CoalitionService {

    @Resource
    private ContactInfoManager contactInfoManager;
    @Resource
    private DemandManager demandManager;
    @Resource
    private TechnicManager technicManager;
    @Resource
    private CompanyManager companyManager;
    @Resource
    private CategoryManager categoryManager;

    @Override
    public Result addContactInfo(ContactInfoDTO contactInfoDTO, HttpServletRequest request) {
        String username = JwtUtils.getUsername(request);
        contactInfoDTO.setUsername(username);
        return contactInfoManager.addContactInfo(contactInfoDTO);
    }

    @Override
    public Result contactDetail(ContactInfoDTO contactInfoDTO, HttpServletRequest request) {
        String username = JwtUtils.getUsername(request);
        contactInfoDTO.setUsername(username);

        return contactInfoManager.contactDetail(contactInfoDTO);
    }

    @Override
    public PageResult demandList(PageRequest pageRequest) {
        return demandManager.list(pageRequest);
    }

    @Override
    public PageResult technicList(PageRequest pageRequest) {
        return technicManager.list(pageRequest);
    }

    @Override
    public PageResult companyList(PageRequest pageRequest) {
        return companyManager.list(pageRequest);
    }

    @Override
    public Result categoryList(Map<String, String> params) {
        return categoryManager.paramsList(params);
    }

}
